package org.glut.wechat.moments.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.glut.wechat.moments.domain.MomentsComment;
import org.glut.wechat.moments.service.MomentsCommentService;
import org.glut.wechat.moments.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 朋友圈评论控制器
 */
@RestController
@RequestMapping("/comment")
@CrossOrigin
public class MomentsCommentController {

    @Autowired
    private MomentsCommentService momentsCommentService;

    /**
     * 发表评论
     * @param comment 评论对象
     * @return 响应结果
     */
    @PostMapping("/publish")
    public Result publishComment(@RequestBody MomentsComment comment) {
        momentsCommentService.publishComment(comment);
        return Result.ok();
    }


    /**
     * 删除评论
     * @param id 评论ID
     * @return 响应结果
     */
    @DeleteMapping("/deleteComment/{id}")
    public Result deleteComment(@PathVariable Integer id) {
       momentsCommentService.deleteComment(id);
       return Result.ok("删除成功");
    }


}
